<?php
 include "counter2.php";
// $self_url = "http://" . $HTTP_HOST . $REQUEST_URI;
 $area = $counter->get_input('area', '', 'get');
 $limit = $counter->get_input('limit', 'number', 'get');

pagestart(); ?>
<html>
<head>
<?php if ( $area ) { ?>
<META HTTP-EQUIV="Refresh" CONTENT="600;URL=./recentusers.php?area=<? echo $area ?>">
<?php } else { ?>
<META HTTP-EQUIV="Refresh" CONTENT="600;URL=./recentusers.php">
<?php } ?>
<?php pagehead(_("Recent changes"), "head") ?>
</head>

<body bgcolor="white">
<?php pagetop() ?>
<table width="95%">
<tr><td>
<img src="/gifs/Logo-small.png" alt="<?php print _("Linux Counter Logo") ?>">
<td align="right">
<font size="+3"><?php print _("Persons:") ?> <?php echo dbcount("persons") ?></font>
<br>
<font size="+3"><?php print _("Lost users:") ?> <?php echo dbcount("users", "state='bad'") ?></font>
<br>
<font size="+3"><?php print _("Frozen users:") ?> <?php echo dbcount("users", "state='frozen'") ?></font>
</table>
<h1><?php print _("The current crop of registrations and changes") ?></h1>
<form action="<?php echo $self_url ?>">
<table>
<tr><td>
<?php print _("This page is supposed to refresh every 10 minutes.") ?>
<br>
<?php print _("It should reflect the stats from") ?> <a href="<?php print $counter_site ?>/reports/hourstats.php"><?php print _("the hourly statistics") ?></a>.
<br><?php print _("Only changes for the last 3 days are shown.") ?>
<p>
<?php print _("Last refresh:") ?>  <?php echo gmstrftime ("%b %d %Y %H:%M:%S",time())."\n"; ?> GMT.
<td>
<?php print _("Limit to area:") ?> <input name="area" value="<?php echo $area ?>">
<input type="submit" value="<?php print _("Reload") ?>">
</table>
</form>
<table border>
<tr><th>#</th><th><?php print _("Modified") ?></th><th><?php print _("Name") ?></th><th><?php print _("City, state, country") ?></th><th><?php print _("PlaceID") ?></th><th><?php print _("Placesource") ?>
<?php
// Following change to select number of lines: ghane - 000630
if ($limit)
	$limit = $limit ;
else
	 $limit  = 21 ;

if ($area) {
	$areaexpr = "placeid like '$area%' and ";
} else {
	$areaexpr = "";
}

$query = mysql_query("select f_key, name, country, state, city, f_mtime, f_ctime, placeid, placesource from persons where $areaexpr f_mtime > date_sub(now(), interval 3 day) order by f_mtime desc limit $limit");
if ($query == 0) {
   print("</table>" . _("MySQL error") . ": " . mysql_errno() . ":" . mysql_error());
   die("Query failed");
}

while ($arr = mysql_fetch_array($query)) {
   $arr["placesource"] = eregi_replace("^clean-", "", $arr["placesource"]);
   $mtime = eregi_replace("^[0-9-]+ ", "", $arr["f_mtime"]); 
   if ($arr["f_mtime"] == $arr["f_ctime"]) {
        echo "<tr><td bgcolor=\"yellow\">", $arr["f_key"], "<td>", $mtime, "<td>";
   } else {
       echo "<tr><td bgcolor=\"#80FF80\">", $arr["f_key"], "<td>", $mtime, "<td>";
   }
   { 
       if ($arr["name"] == "") { $arr["name"] = "nameless"; }
       echo "<a href=\"/cgi-bin/adm/display-person.cgi?user=", $arr["f_key"], "\">",
	   $arr["name"], "</a>";
   }
   echo "<td>", $arr["city"], ", ", $arr["state"], ", ", $arr["country"];
   echo "<td>", "<a href=\"/cgi-bin/adm/place.cgi?place=", urlencode($arr["placeid"]), "\">", $arr["placeid"], "</a>";
   echo "<td>", $arr["placesource"];
   echo "<br>\n";
}

?>
</table>
<p>
<table>
<tr><td bgcolor="yellow"><?php print _("new entries") ?></td>
<tr><td bgcolor="#80FF80"><?php print _("updated entries") ?></td>
<tr><td><?php print _("Try this URL as") ?> <a href="./recentusers.php?limit=15">http://counter.li.org/adm/recentusers.php?limit=15</a> <?php print _("if you want a smaller table") ?></td>
</table>

<?php pagebottom("yes") ?>
</body>
</html>
